#pragma once
#include <string>
#include <vector>
#include <cstring>
#include <sys/socket.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>

#define MAXLINE 40960

class Client{
    private:
        int                         c_port;
        char const                 *c_address;
        char const                 *c_output_file_name;
        char const                 *c_download_file_name;
        int                         sockfd;
        int                         len;
        char                        recv_buff[MAXLINE];
        char                        send_buff[MAXLINE];
        int                         recv_num;
        int                         send_num;
        struct sockaddr_in          c_server_address;
        FILE                       *fq;


    public:
        Client();
        void                set_port(int port);
        void                set_address(char const* address);
        void                set_output_file_name(char* file_name);
        void                set_download_file_name(char* file_name);
        int                 get_port();
        char const*         get_address();

        // start a socket client
        int                 create_socket();
        void                init_address();
        int                 connect_socket();
        void                close_sockfd();
        void                read_buffer();
        void                request_list();
        void                request_file(int is_download, int is_output);
        void                write_send_buffer(std::string content);
        void                send_to_server();
        void                download_file();

        // print the help of Client
        static void         print_help();


        ~Client();
};